﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Data.Linq;
using System.Data.Linq.Mapping;
using System.Text;
using System.Reflection;
using SDT.DataService;

namespace SDT.DataService.Contexts
{
    /// <summary>
    /// Kết nối database : BDS.Spider
    /// </summary>
    public class NewsContext : BDS_SpiderDataContext
    {
        #region Function WC


        [Function(Name = "dbo.sp_WC_News_ReplaceImage")]
        public int sp_WC_News_ReplaceImage([Parameter(Name = "PageId", DbType = "Int")] System.Nullable<int> pageId, [Parameter(Name = "Content", DbType = "NText")] string content, [Parameter(Name = "Status", DbType = "TinyInt")] System.Nullable<byte> status)
        {
            IExecuteResult result = this.ExecuteMethodCall(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())), pageId, content, status);
            return ((int)(result.ReturnValue));
        }

        [Function(Name = "dbo.sp_News_DuplicatedNews")]
        public int sp_News_DuplicatedNews([Parameter(Name = "@SecondNewsID", DbType = "Int")] System.Nullable<int> newID, [Parameter(Name = "Title", DbType = "NVarChar(2000)")] string title)
        {
            IExecuteResult result = this.ExecuteMethodCall(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())), newID, title);
            return ((int)(result.ReturnValue));
        }


        [Function(Name="dbo.sp_WC_Article_Insert")]
		public int sp_WC_Article_Insert(
					[Parameter(Name="ChannelId", DbType="Int")] System.Nullable<int> channelId, 
					[Parameter(Name="PageId", DbType="Int")] System.Nullable<int> pageId, 
					[Parameter(Name="CateID", DbType="Int")] System.Nullable<int> cateID, 
					[Parameter(Name="NewsType", DbType="Int")] System.Nullable<int> newsType, 
					[Parameter(Name="CreatedDate", DbType="DateTime")] System.Nullable<System.DateTime> createdDate, 
					[Parameter(Name="Title", DbType="NVarChar(500)")] string title, 
					[Parameter(Name="Lead", DbType="NText")] string lead, 
					[Parameter(Name="Content", DbType="NText")] string content, 
					[Parameter(Name="ContentRawHTML", DbType="NText")] string contentRawHTML,
                    [Parameter(Name = "FTS", DbType = "Text")] bool fTS,
                    [Parameter(Name = "PubYN", DbType = "Bit")] bool pubYN, 
					[Parameter(Name="OriginalUrl", DbType="NVarChar(400)")] string originalUrl, 
					[Parameter(Name="ImageDesc", DbType="NVarChar(500)")] string imageDesc, 
					[Parameter(Name="Status", DbType="TinyInt")] System.Nullable<byte> status, 
					[Parameter(Name="ManualTitle", DbType="VarChar(200)")] string manualTitle, 
					[Parameter(Name="MetaTitle", DbType="NVarChar(200)")] string metaTitle, 
					[Parameter(Name="MetaDescription", DbType="NVarChar(400)")] string metaDescription, 
					[Parameter(Name="MetaKeyword", DbType="NVarChar(400)")] string metaKeyword, 
					[Parameter(Name="MetaTags", DbType="NVarChar(400)")] string metaTags)
		{
            IExecuteResult result = this.ExecuteMethodCall(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())), channelId, pageId, cateID, newsType, createdDate, title, lead, content, contentRawHTML, fTS, pubYN, originalUrl, imageDesc, status, manualTitle, metaTitle, metaDescription, metaKeyword, metaTags);
			return ((int)(result.ReturnValue));
		}

        [Function(Name = "dbo.sp_WC_GetPreviousArticle")]
        public ISingleResult<sp_WC_GetPreviousArticleResult> sp_WC_GetPreviousArticle([Parameter(Name = "ArtID", DbType = "Int")] System.Nullable<int> artID)
        {
            IExecuteResult result = this.ExecuteMethodCall(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())), artID);
            return ((ISingleResult<sp_WC_GetPreviousArticleResult>)(result.ReturnValue));
        }
        [Function(Name = "dbo.sp_ad_article_update_metakey_tag")]
        public int sp_ad_article_update_metakey_tag([Parameter(Name = "ArticleID", DbType = "Int")] System.Nullable<int> iD, [Parameter(Name = "MetaKeyword", DbType = "NVarChar(4000)")] string metaKeyWord, [Parameter(Name = "MetaTags", DbType = "NVarChar(4000)")] string metaTag)
        {
            IExecuteResult result = this.ExecuteMethodCall(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())), iD, metaKeyWord, metaTag);
            return ((int)(result.ReturnValue));
        }
        #endregion

        #region MD
        [Function(Name = "dbo.sp_WC_News_GetByID")]
        public ISingleResult<sp_WC_News_GetByIDResult> sp_WC_News_GetByID([Parameter(Name = "PageId", DbType = "Int")] System.Nullable<int> pageId)
        {
            IExecuteResult result = this.ExecuteMethodCall(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())), pageId);
            return ((ISingleResult<sp_WC_News_GetByIDResult>)(result.ReturnValue));
        }
        #endregion

        #region Check Duplicate
        [Function(Name = "dbo.sp_WC_DuplicatedArticle_Insert")]
        public int sp_WC_DuplicatedArticle_Insert([Parameter(Name = "ArticleID", DbType = "Int")] System.Nullable<int> articleID, [Parameter(Name = "OtherArticleID", DbType = "Int")] System.Nullable<int> otherArticleID, [Parameter(Name = "DuplicatedRate", DbType = "Float")] System.Nullable<double> duplicatedRate)
        {
            IExecuteResult result = this.ExecuteMethodCall(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())), articleID, otherArticleID, duplicatedRate);
            return ((int)(result.ReturnValue));
        }

        #endregion

    }
}
